package com.example.java2024712;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
public class RequestController {
    @RequestMapping("param1")
    public String paramq(String userName) {
        System.out.println("1接收到的参数："+userName);
        return "接收到参数：" + userName;
    }
    @RequestMapping("/param2")
    public String param2(Integer age) {
        return "2接收的参数: "+age;
    }
    @RequestMapping("/param3")
    public String param3(int age) {
        return "3接收的参数: "+ age;
    }
    @RequestMapping("/param4")
    public String param4(String username, String password) {
        return "接收到的参数："+username +",password: "+password;
    }
    @RequestMapping("/param5")
    public String param5 (UserInfor userInfor) {
        return "接收到的参数UserInfo: "+userInfor;
    }
    @RequestMapping("/param6")
    //对变量进进学绑定
    public String param6(@RequestParam(value = "username",required = false)String name ,String password) {
        return "接收到的参数name："+name+",password: "+password;
    }
    @RequestMapping("/param7")
    //传递数组
    public String param7(String[] arrParams) {
        return "接收到的参数arrParam："+ Arrays.toString(arrParams);
    }
}
